import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'

export default createStore({
  state: {
    // 登录token
    token: localStorage.getItem('token') ? localStorage.getItem('token') : '',
    
    //Tabs 标签页
    // openTab:[],//所有打开的路由
    // activeIndex: '/index' // 激活状态
  },
  mutations: {
    //存储token
    setToken(state,token){
      state.token = token;
      localStorage.setItem("token",token.token)//存储token
    },
    // //删除token
    // delToken(){
    //   localStorage.removeItem("token");
    // },

    // //添加tabs
    // addTabs(state, data){
    //   state.openTab.push(data);
    // },

    // changeTabs(state, route){
    //   state.activeTab = route;
    // },
    // deductTabs(state, route) {
    //   let index = state.openedTab.indexOf(route)
    //   state.openedTab.splice(index, 1)
    // }
  },

  actions: {
  },
  modules: {
  },
  plugins: [(createPersistedState)]
})
